package usw.dao;

import org.springframework.stereotype.Repository;
import usw.entity.Employee;
import usw.framework.minidao.annotation.Arguments;
import usw.framework.minidao.annotation.MiniDao;
import usw.framework.minidao.annotation.ResultType;
import usw.framework.minidao.annotation.Sql;
import usw.framework.minidao.entity.MiniDaoPage;

import java.util.List;
import java.util.Map;


/**
 *
 */
@MiniDao
public interface EmployeeDao {

    /**
     * 返回List<Map>类型，全部数据
     * @param employee
     * @return
     */
    @Arguments({ "employee"})
    List<Map<String,Object>> getAll(Employee employee);

    /**
     * 查询返回Java对象
     * @param empno
     * @return
     */
    @Arguments("empno")
    Employee getEmployee(String empno);

    /**
     * 支持多个参数，查看返回Map
     * @param empno
     * @param name
     * @return
     */
    @Arguments({ "empno", "name"})
    Map<String,Object> getMap(String empno, String name);

    /**
     * 修改数据
     * @param employee
     * @return
     */
    @Arguments("employee")
    int update(Employee employee);

    /**
     * 插入数据
     * @param employee
     */
    @Arguments("employee")
    void insert(Employee employee);

    /**
     * 通用分页方法
     * @param employee
     * @param page
     * @param rows
     * @return
     */
    @Arguments({ "employee", "page", "rows" })
    @ResultType(Employee.class)
    public MiniDaoPage<Employee> getAllEmployees(Employee employee, int page, int rows);

    @Sql("select count(*) from employee")
    Integer getCount();
}
